package com.team2.outpatient_sys.dao;

import com.team2.outpatient_sys.pojo.ShowUnqualifiedMedicine;
import com.team2.outpatient_sys.pojo.UnqualifiedMedicine;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UnqualifiedMedicineDao {

    //增加有问题的药品
    @Insert("insert into unqualified_medicine(description,medicine_id,record_time,cont) values(#{description},#{medicineId},#{recordTime},#{cont})")
    public Integer add(UnqualifiedMedicine unqualifiedMedicine);

    @Results({
            @Result(column = "medicine_id" ,property = "medicine",
                    one = @One (
                            select = "com.team2.outpatient_sys.dao.MedicineDao.findAllById")
            )
    })
    @Select("select * from unqualified_medicine where shelves = '否'")
    List<ShowUnqualifiedMedicine> findAllNO();

    @Results({
            @Result(column = "medicine_id" ,property = "medicine",
                    one = @One (
                            select = "com.team2.outpatient_sys.dao.MedicineDao.findAllById")
            )
    })
    @Select("select * from unqualified_medicine where shelves = '是'")
    List<ShowUnqualifiedMedicine> findAllYES();

    @Update("update unqualified_medicine set shelves='是' where id = #{id}")
    Integer UpdateStorageOut(Integer id);

    @Update("update unqualified_medicine set description=#{description},cont=#{cont} where id = #{id}")
    Integer update(UnqualifiedMedicine unqualifiedMedicine);
}
